import React, { FC, useEffect, useState } from "react";
import { Tabs } from "antd";
import { FileTextOutlined, SettingOutlined } from "@ant-design/icons";
import ComponentProps from "../componentProp";
import styles from "./index.module.scss";
import PageSetting from "../pageSetting";
import useGetComponentInfo from "../../../../hooks/useGetComponentInfo";
//枚举
enum TAB_KEYS {
  PROP_KEY = "prop",
  SETTING_KEY = "setting",
}
const RightPanel: FC = () => {
  const { selectedId } = useGetComponentInfo();
  const [activeKey, setActiveKey] = useState(TAB_KEYS.PROP_KEY);
  useEffect(() => {
    if (selectedId) setActiveKey(TAB_KEYS.PROP_KEY);
    else setActiveKey(TAB_KEYS.SETTING_KEY);
  }, [selectedId]);

  const tabsItem = [
    {
      key: TAB_KEYS.PROP_KEY,
      label: (
        <span>
          <FileTextOutlined />
          属性
        </span>
      ),
      children: <ComponentProps />,
    },
    {
      key: TAB_KEYS.SETTING_KEY,
      label: (
        <span>
          <SettingOutlined />
          页面设置
        </span>
      ),
      children: <PageSetting />,
    },
  ];

  return (
    <div className={styles.tabList}>
      <Tabs activeKey={activeKey} items={tabsItem}></Tabs>
    </div>
  );
};

export default RightPanel;
